<template>
    <view class="container">
        <view class="head">
            <icon size="93" type="info"></icon>
        </view>
        <view class="text">是否核销此订单</view>
        <view class="btn">
            <button @tap="hx" class="weui-btn" :style="'background-color:' + color" type="primary">确定</button>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            moid: '',
            msjid: '',
            storeid: '',
            smuid: '',
            admin_id: '',
            color: ''
        };
    },
    onLoad: function (t) {
        app.globalData.setNavigationBarColor(this);
        var that = this;
        console.log(t);
        var e = decodeURIComponent(t.scene);
        console.log(e, e.split(','));
        var i = e.split(',')[1]; //订单id
        var n = e.split(',')[0]; //门店id
        var a = t.storeid;
        this.setData({
            moid: i,  //订单id
            msjid: n,  //门店id
            storeid: a //扫码人的门店id
        });
        uni.showLoading({
            title: '加载中'
        });
        app.globalData.getUserInfo(function (t) {
            console.log(t);
            that.setData({
                smuid: t.id
            });
        });
        app.globalData.util.request({
            url: 'entry/wxapp/StoreInfo',
            cachetime: '0',
            data: {
                store_id: n
            },
            success: function (t) {
                console.log('小店详情', t);
                that.setData({
                    admin_id: t.data.store.admin_id
                });
            }
        });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
    methods: {
        hx: function () {
            var o = getCurrentPages();
            console.log(o);
            var t = this.storeid;
            var e = this.admin_id;
            var i = this.smuid;
            var n = this.moid;
            var a = this.msjid;
            console.log('扫码人的storeid', t, 'smuid', i, 'admin_id', e, '订单id', n, 'msjid', a);
            // if (t == a || e == i) {
            if (t == a ) {
                app.globalData.util.request({
                    url: 'entry/wxapp/OkOrder',
                    cachetime: '0',
                    data: {
                        order_id: n
                    },
                    success: function (t) {
                        console.log(t);
                        if ('1' == t.data) {
                            uni.showToast({
                                title: '核销成功',
                                icon: 'success',
                                duration: 1000
                            });
                            setTimeout(function () {
                                if (1 < o.length) {
                                    setTimeout(function () {
                                        uni.navigateBack({});
                                    }, 1000);
                                } else {
                                    uni.reLaunch({
                                        url: '/ymq_canyino2o/pages/Liar/loginindex'
                                    });
                                }
                            }, 1000);
                        } else {
                            uni.showToast({
                                title: '请重试',
                                icon: 'loading',
                                duration: 1000
                            });
                        }
                    }
                });
            } else {
                uni.showModal({
                    title: '提示',
                    content: '您暂无核销权限'
                });
                setTimeout(function () {
                    if (1 < o.length) {
                        setTimeout(function () {
                            uni.navigateBack({});
                        }, 1000);
                    } else {
                        uni.reLaunch({
                            url: '/ymq_canyino2o/pages/Liar/loginindex'
                        });
                    }
                }, 1000);
            }
        }
    }
};
</script>
<style>
@import './hx.css';
</style>
